Page({
    data: {
        src: '',
        width: 250, //宽度
        height: 250, //高度
        showMiddle: true, //是否显示裁剪框
        showOptions: true,
        buttons: [{
            type: 'primary',
            className: '',
            text: '识别其他作物',
            value: 0
        }],
        show: false,
        imageList: [{
                id: 0,
                src: '../../../images/banner.png'
            },
            {
                id: 1,
                src: '../../../images/banner.png'
            },
            {
                id: 2,
                src: '../../../images/banner.png'
            },
            {
                id: 3,
                src: '../../../images/banner.png'
            },
            {
                id: 4,
                src: '../../../images/banner.png'
            },
            {
                id: 5,
                src: '../../../images/banner.png'
            },
            {
                id: 6,
                src: '../../../images/banner.png'
            },
            {
                id: 7,
                src: '../../../images/banner.png'
            },
            {
                id: 8,
                src: '../../../images/banner.png'
            },
            {
                id: 9,
                src: '../../../images/banner.png'
            },
        ]
    },
    onLoad: function (options) {
        //获取到image-cropper实例
        this.cropper = this.selectComponent("#image-cropper");
        //开始裁剪
        this.setData({
            src: options.src,
        });
        wx.showLoading({
            title: '加载中'
        })
    },
    onShow: function () {
        wx.hideLoading()
        this.setData({
            showOptions: false,
        });
    },

    open: function () {
        this.setData({
            show: true
        })
    },
    close: function () {
        console.log(1111, this.data.show)
        this.setData({
            show: false
        })
    },
    buttontap(e) {
        console.log(e.detail)
        wx.navigateTo({
            url: `/pages/virus_recognition/virus_result/index`,
            success: function (res) {
                wx.setNavigationBarTitle({
                    title: '识别结果'
                })
                // 通过eventChannel向被打开页面传送数据
                // res.eventChannel.emit('acceptDataFromOpenerPage', { data: 'test' })
            }
        })
    },


    cropperload(e) {
        console.log("cropper初始化完成");
    },
    loadimage(e) {
        console.log("图片加载完成", e.detail);
        wx.hideLoading();
        //重置图片角度、缩放、位置
        this.cropper.imgReset();
    },
    changeMiddle() {
        this.setData({
            showMiddle: !this.data.showMiddle
        })
    },
    clickcut(e) {
        console.log(e.detail);
        //点击裁剪框阅览图片
        wx.previewImage({
            current: e.detail.url, // 当前显示图片的http链接
            urls: [e.detail.url] // 需要预览的图片http链接列表
        })
    },
    select(e) {
        console.log(e);
    },
})